#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define MaxSize 100

typedef int ElemType;
typedef struct Stack{
    ElemType data[MaxSize];
    int top;
}SqStack;

/*
    栈有两种方式，栈顶指针初始放在-1或者0两种，两种入栈出栈方式++i或者i++；
*/

void initStack(SqStack *S);
bool push(SqStack *S, ElemType elem);
bool pop(SqStack *S, ElemType *elem);
bool getTop(SqStack S, ElemType *elem);

int main(){
    SqStack S;
    int elem = 0;
    initStack(&S);
    push(&S, 100);
    getTop(S, &elem);
    printf("%d\n", elem);
    return 0;
}

void initStack(SqStack *S){
    S->top = -1;
}

bool push(SqStack *S, ElemType elem){
    if(S->top==MaxSize-1) return false;
    S->data[++S->top] = elem;
    return true;
}

bool pop(SqStack *S, ElemType *elem){
    if(S->top==-1) return false;
    *elem = S->data[S->top--];
    return true;
}

bool getTop(SqStack S, ElemType *elem){
    if(S.top==-1) return false;
    *elem = S.data[S.top];
    return true;
}